package com.huluobo.a2202mvvm_im_douyindemo.addGroup;

import androidx.lifecycle.MutableLiveData;

import com.huluobo.a2202mvvm_im_douyindemo.mvvmBase.BaseViewModel;
import com.hyphenate.chat.EMGroup;
import com.hyphenate.chat.EMGroupInfo;
import com.hyphenate.chat.EMGroupOptions;

import java.util.List;

/**
 * Created by LC on 2024/4/24.
 */
public class AddGroupViewModel extends BaseViewModel<AddGroupRepo> {
    MutableLiveData<String> createGroupSuccess = new MutableLiveData<>();
    MutableLiveData<String> createGroupFailed = new MutableLiveData<>();

    MutableLiveData<List<EMGroupInfo>> findGroupSuccess = new MutableLiveData<>();
    MutableLiveData<String> findGroupFailed = new MutableLiveData<>();

    MutableLiveData<String> joinGroupSuccess = new MutableLiveData<>();
    MutableLiveData<String> joinGroupFailed = new MutableLiveData<>();

    MutableLiveData<List<EMGroup>> findJoinedGroupSuccess = new MutableLiveData<>();
    MutableLiveData<String> findJoinedGroupFailed = new MutableLiveData<>();

    public void findJoinedGroup() {
        repo.findJoinedGroup(findJoinedGroupSuccess, findJoinedGroupFailed);
    }

    public void joinGroup(String groupId) {
        repo.joinGroup(groupId, joinGroupSuccess, joinGroupFailed);
    }

    public void findGroup(int pageSize, String cursor) {
        repo.findGroup(pageSize, cursor, findGroupSuccess, findGroupFailed);
    }

    public void createGroup(String groupName,
                            String desc,
                            String[] allMembers,
                            String reason,
                            EMGroupOptions option) {
        repo.createGroup(groupName, desc, allMembers, reason, option, createGroupSuccess, createGroupFailed);
    }

    @Override
    protected AddGroupRepo createRepo() {
        return new AddGroupRepo();
    }
}
